// 格式化时间函数
function dateFormat(dateStr) {
  const dt = new Date(dateStr);

  const year = dt.getFullYear();
  const month = padZero(dt.getMonth() + 1);
  const days = padZero(dt.getDate());

  const hours = padZero(dt.getHours());
  const minutes = padZero(dt.getMinutes());
  const seconds = padZero(dt.getSeconds());

  return `${year}-${month}-${days} ${hours}:${minutes}:${seconds}`;
}

// 补零函数
function padZero(n) {
  return n > 9 ? n : "0" + n;
}

module.exports = {
  dateFormat
};
